Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(meta): add self-referential canonical link #257

Merged
merged 2 commits into from
Aug 24, 2023

Conversation

machikoyasuda
Copy link
Member

@machikoyasuda machikoyasuda commented Aug 24, 2023

closes #265

What this PR does

  • Add <link rel="canonical" href="{{ page.url | absolute_url }}" /> set to the absolute URL

Why

Asking social media companies to recognize these calitp.org links!

Should a page have a self-referencing canonical URL?

In the image above, we link the non-canonical page to the canonical version. But should a page set a rel=canonical for itself? This question is a much-debated topic amongst SEOs. At Yoast, we strongly recommend having a canonical link element on every page, and Google has confirmed that’s best. That’s because most CMSs will allow URL parameters without changing the content. So all of these URLs would show the same content:

https://example.com/wordpress/seo-plugin/
https://example.com/wordpress/seo-plugin/?isnt=it-awesome
https://example.com/wordpress/seo-plugin/?cmpgn=twitter
https://example.com/wordpress/seo-plugin/?cmpgn=facebook

The issue is that if you don’t have a self-referencing canonical on the page that points to the cleanest version of the URL, you risk being hit by this. And if you don’t do it yourself, someone else could do it to you and cause a duplicate content issue. So adding a self-referencing canonical to URLs across your site is a good “defensive” SEO move. Luckily, our Yoast SEO plugin takes care of this for you.

rel=canonical and social networks

Facebook and Twitter honor rel=canonical too, and this might lead to weird situations. If you share a URL on Facebook with a canonical pointing elsewhere, Facebook will share the details from the canonical URL. In fact, if you add a ‘like’ button on a page that has a canonical pointing elsewhere, it will show the like count for the canonical URL, not for the current URL. Twitter works in the same way. So be aware of this when sharing URLs or when using these buttons.

☝️ My hypothesis is that this is what's happening to calitp.org/* links right now, based on what I've seen on the LinkedIn and Facebook link validators, showing the canonical url as calitp.org, instead of the full link.

image
image

@machikoyasuda machikoyasuda requested a review from a team as a code owner August 24, 2023 19:13
@machikoyasuda machikoyasuda self-assigned this Aug 24, 2023
@netlify
Copy link

netlify bot commented Aug 24, 2023

Deploy Preview for cal-itp-website ready!

Name Link
🔨 Latest commit c15317d
🔍 Latest deploy log https://app.netlify.com/sites/cal-itp-website/deploys/64e7ac749d4d9d0008d74fe8
😎 Deploy Preview https://deploy-preview-257--cal-itp-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@machikoyasuda machikoyasuda merged commit 69336a5 into main Aug 24, 2023
4 checks passed
@machikoyasuda machikoyasuda deleted the fix/265-canonical-link branch August 24, 2023 19:19
@machikoyasuda machikoyasuda linked an issue Aug 24, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix: Add canonical url to pages
3 participants